package com.training.java.module2;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public class QuestionsCollection {

    private List<Question> questions;

    private QuestionsCollection(){
        questions = new ArrayList<Question>();
    }

    private static class QuestionsCollectionHolder {
        private static final QuestionsCollection INSTANCE = new QuestionsCollection();
    }

    public static QuestionsCollection getInstance() {
        return QuestionsCollectionHolder.INSTANCE;
    }

    public void addQuestion(String unparsedString){
        questions.add(Question.factory(unparsedString));
    }

    public void printQuestionTitle(int questionId){
        System.out.println(questions.get(questionId));
    }

    public boolean isCorrectAnswer(int questionId){
        return questions.get(questionId).isCorrectAnswer();
    }
    public int getQuestionsCollectionSize(){
        return questions.size();
    }

    public void shuffleQuestions(){
        Collections.shuffle(questions);
    }


}
